myStorage = window.localStorage;
//post Request Parameter: url:[api url];data:[post data];;callback:[callback]
 // var api = "http://115.28.252.231/app-controller";
//  var href = "http://47.104.8.133:8083/h5-web";
function getRequest(url, data, callback) {
    $.ajax({
        url: url,
        data: data,
        type: "GET",
        dataType: 'json',
        success: function (resData) {
            //callback
            if (typeof callback == 'function') {
                callback(resData);
            }
        }
    })
}
//post Request Parameter: url:[api url];data:[post data];;callback:[callback]
function postRequest(url, data, callback) {
    $.ajax({
        url: url,
        data: data,
        type: "POST",
        dataType: 'json',
        success: function (resData) {
            //callback
            if (typeof callback == 'function') {
                callback(resData);
            }
        }
    })
}

//设置缓存
function createStorage(name, value) {
    myStorage.setItem(name, value);
}

function readStorage(name) {
    return myStorage.getItem(name);
}

//根据名字清空cookie
function removeStorage(name) {
    myStorage.removeItem(name);
}


//只能微信打开
function onlyWechat() {
    var useragent = navigator.userAgent;
    if (useragent.match(/MicroMessenger/i) != 'MicroMessenger') {
        window.location.href = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxdf3f22ebfe96b912&redirect_uri=xxx&response_type=code&scope=snsapi_base&state=hyxt#wechat_redirect';
    }
}
//提交按钮5秒才可点击 
 var countdown = 10;
function settime(obj) { //发送验证码倒计时
    if (countdown == 0) {
        obj.attr('disabled', false);
        obj.val("");
        countdown =10;
        return;
    } else {
        obj.attr('disabled', true);
        obj.val("");
        countdown--;
    }
    setTimeout(function () {
        settime(obj)
    }
        , 1000)
}
